﻿@model NeverSoldReportSearchModel

@{
    //page title
    ViewBag.PageTitle = T("Admin.Reports.Sales.NeverSold").Text;
    //active menu item (system name)
    NopHtml.SetActiveMenuItemSystemName("Products never purchased");
}

@{
    const string hideSearchBlockAttributeName = "NeverSoldReportPage.HideSearchBlock";
    var hideSearchBlock = await genericAttributeService.GetAttributeAsync<bool>(await workContext.GetCurrentCustomerAsync(), hideSearchBlockAttributeName);
}

<div class="content-header clearfix">
    <h1 class="float-left">
        @T("Admin.Reports.Sales.NeverSold")
    </h1>
    <div class="float-right">
        &nbsp;
    </div>
</div>

<section class="content">
    <div class="container-fluid">
    <div class="form-horizontal">
        <div class="cards-group">
            <div class="card card-default card-search">
                <div class="card-body">
                    <div class="row search-row @(!hideSearchBlock ? "opened" : "")" data-hideAttribute="@hideSearchBlockAttributeName">
                        <div class="search-text">@T("Admin.Common.Search")</div>
                        <div class="icon-search"><i class="fas fa-magnifying-glass" aria-hidden="true"></i></div>
                        <div class="icon-collapse"><i class="far fa-angle-@(!hideSearchBlock ? "up" : "down")" aria-hidden="true"></i></div>
                    </div>

                    <div class="search-body @(hideSearchBlock ? "closed" : "")">
                        <div class="row">
                            <div class="col-md-5">
                                <div class="form-group row" @(Model.AvailableCategories.SelectionIsNotPossible() ? Html.Raw("style=\"display:none\"") : null)>
                                    <div class="col-md-4">
                                        <nop-label asp-for="SearchCategoryId" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-select asp-for="SearchCategoryId" asp-items="Model.AvailableCategories" />
                                    </div>
                                </div>
                                <div class="form-group row" @(Model.AvailableManufacturers.SelectionIsNotPossible() ? Html.Raw("style=\"display:none\"") : null)>
                                    <div class="col-md-4">
                                        <nop-label asp-for="SearchManufacturerId" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-select asp-for="SearchManufacturerId" asp-items="Model.AvailableManufacturers" />
                                    </div>
                                </div>
                                <div class="form-group row" @(Model.AvailableStores.SelectionIsNotPossible() ? Html.Raw("style=\"display:none\"") : null)>
                                    <div class="col-md-4">
                                        <nop-label asp-for="SearchStoreId" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-select asp-for="SearchStoreId" asp-items="Model.AvailableStores" />
                                    </div>
                                </div>
                                <div class="form-group row" @(Model.AvailableVendors.SelectionIsNotPossible() || Model.IsLoggedInAsVendor ? Html.Raw("style='display: none;'") : null)>
                                    <div class="col-md-4">
                                        <nop-label asp-for="SearchVendorId" />
                                    </div>
                                    <div class="col-md-8">
                                        <nop-select asp-for="SearchVendorId" asp-items="Model.AvailableVendors" />
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-7">
                                <div class="form-group row">
                                    <div class="col-md-3">
                                        <nop-label asp-for="StartDate" />
                                    </div>
                                    <div class="col-md-9">
                                        <nop-editor asp-for="StartDate" />
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <div class="col-md-3">
                                        <nop-label asp-for="EndDate" />
                                    </div>
                                    <div class="col-md-9">
                                        <nop-editor asp-for="EndDate" />
                                    </div>
                                </div>
                            </div>                            
                        </div>
                        <div class="row">
                            <div class="text-center col-12">
                                <button type="button" id="search-neversoldreport" class="btn btn-primary btn-search">
                                    <i class="fas fa-chart-line"></i>
                                    @T("Admin.Reports.Sales.NeverSold.RunReport")
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="card card-default">
                <div class="card-body">
                    <nop-doc-reference asp-string-resource="@T("Admin.Documentation.Reference.Reports", Docs.Reports + Utm.OnAdmin)" />

                    @await Html.PartialAsync("Table", new DataTablesModel
                    {
                        Name = "neversoldreport-grid",
                        UrlRead = new DataUrl("NeverSoldList", "Report", null),
                        SearchButtonId = "search-neversoldreport",
                        Length = Model.PageSize,
                        LengthMenu = Model.AvailablePageSizes,
                        Filters = new List<FilterParameter>
                        {
                            new FilterParameter(nameof(Model.StartDate), typeof(DateTime?)),
                            new FilterParameter(nameof(Model.EndDate), typeof(DateTime?)),
                            new FilterParameter(nameof(Model.SearchCategoryId)),
                            new FilterParameter(nameof(Model.SearchManufacturerId)),
                            new FilterParameter(nameof(Model.SearchStoreId)),
                            new FilterParameter(nameof(Model.SearchVendorId))
                        },
                        ColumnCollection = new List<ColumnProperty>
                        {
                            new ColumnProperty(nameof(NeverSoldReportModel.ProductName))
                            {
                                Title = T("Admin.Reports.Sales.NeverSold.Fields.Name").Text
                            },
                            new ColumnProperty(nameof(NeverSoldReportModel.ProductId))
                            {
                                Title = T("Admin.Common.Edit").Text,
                                Width = "100",
                                ClassName =  NopColumnClassDefaults.Button,
                                Render = new RenderButtonView(new DataUrl("~/Admin/Product/Edit/"))
                            }
                        }
                    })
                </div>
            </div>
        </div>
    </div>
</div>
</section>